@extends('admin.layout.base')
@section('styles')
@endsection
@section('content')
    <div class="panel-content" id="app" v-cloak>
        <div class="panel-body panel-info">
            <el-form :model="form" ref="form" class="form" label-width="100px" >
                <div class="panel-header"> <div class="panel-title"> 申请人信息 </div> </div>
                <div class="panel-main">
                    <el-form-item label="申请人：" prop="user_name">
                        <el-input readonly v-model="form.user_name"></el-input>
                    </el-form-item>
                     <el-form-item label="申请人电话：" prop="phone">
                        <el-input readonly v-model="form.user_name"></el-input>
                    </el-form-item>
                    
                    
                    <el-form-item label="申请金额：" prop="useramount">
                        <el-input readonly v-model="form.useramount"></el-input>
                    </el-form-item>
                    <el-form-item label="实付金额：" prop="amount">
                        <el-input readonly v-model="form.amount"></el-input>
                    </el-form-item>
                    
                    <el-form-item label="收款方式：" prop="pay_type_text">
	                        <el-input readonly v-model="form.pay_type_text"></el-input>
	                 </el-form-item>
                    
                    
                    <div v-if="form.pay_type == 1">
	                    <el-form-item label="收款银行：" prop="bank_name">
	                        <el-input readonly v-model="form.bank_name"></el-input>
	                    </el-form-item>
	                    <el-form-item label="收款卡号：" prop="bank_no">
	                        <el-input readonly v-model="form.bank_no"></el-input>
	                    </el-form-item>
	                    <el-form-item label="开户行姓名：" prop="bank_user">
	                        <el-input readonly v-model="form.bank_user"></el-input>
	                    </el-form-item>                    
                    </div>
                    <div v-else>
                    	<el-form-item label="收款二维码：" prop="qrcode">
	                       <img :src="form.qrcode" style="height: 200px;width: 200px;"/>
	                    </el-form-item>
	                    <el-form-item label="收款账号：" prop="paycount">
	                        <el-input readonly v-model="form.paycount"></el-input>
	                    </el-form-item>
	                    
                    </div>
                    
                    <el-form-item label="申请时间：" prop="created_at">
                        <el-input readonly v-model="form.created_at"></el-input>
                    </el-form-item>
                </div>
                <div class="panel-header"> <div class="panel-title"> 审核信息 </div> </div>
                <div class="panel-main">
                    <el-form-item label="是否支付：" prop="status">
                        <el-radio-group  v-model="form.status">
                            
                            <el-radio :label="2" border>确认支付</el-radio>
                            <el-radio :label="3" border>驳回</el-radio>
                        </el-radio-group>
                    </el-form-item>
                    
                    <el-form-item label="驳回理由：" prop="remark">
                        <el-input type="textarea" rows="3" v-model="form.remark"></el-input>
                    </el-form-item>
                    
                    <el-form-item label="支付管理员：" prop="payment_admin">
                        <el-input readonly v-model="form.payment_admin"></el-input>
                    </el-form-item>
                    <el-form-item label="付款时间：" prop="payment_time">
                        <el-input readonly v-model="form.payment_time"></el-input>
                    </el-form-item>
                </div>
                <el-form-item style="padding-left: 150px;margin-top: 100px">
                	<el-button v-if="status == 1" type="primary" @click="update()">确 定</el-button>
                    <el-button @click="back()" style="margin-left: 50px">返 回</el-button>
                </el-form-item>
            </el-form>
        </div>
    </div>
@endsection
@section('scripts')
    <script>
        let app = new Vue({
            el: '#app',
            data: function() {
                return {
                    status:1,
                    form:{!! $info !!},
                }
            },
            created(){
                
                this.form.password = '';
                this.form._token = "{{csrf_token()}}";
                if(this.form.status>1){
                	 this.status = 0
                }
               
            },
            methods: {
                //返回
                back(){
                    window.history.go(-1);
                },
                update(){
                	let that = this;
                    this.$refs['form'].validate((valid) => {
                        if (valid) {
                            if(this.form.status == 3 && !this.form.remark){
                            	
								alert("请填写驳回理由");
								return 
                            }
                            let that = this;
                            $.post("{{ route('admin.cash.update') }}",this.form,function (res) {
                                if(res.code){
                                    that.$message.error(res.msg);
                                }else{
                                    that.$message({
                                        type: 'success',
                                        duration: '1000',
                                        message: res.msg,
                                        onClose:() =>{
                                            window.history.go(-1);
                                        }
                                    });
                                }
                            },'JSON');
                        }
                    });
               	}
            }
        });
    </script>
@endsection
